proc() {
    echo -e "\033[42;32m > $@ \033[0m" >&2
    local command=("$@")
    if "${command[@]}"; then
        echo -e "\033[42;32m SUCCEED \033[0m \n" >&2
    else
        echo -e "\033[41;32m FAILED \033[0m \n" >&2
        exit 1
    fi
}

clear;

PRJNAME="console"
IP="192.168.3.53"
BDPATH="/root/app"
LVGLPATH="/home/raii/GitHubToyBox/lvglCollection"

# building app
proc cp lv_drv_conf.h ${LVGLPATH}/lv_drivers
proc make

proc ssh root@${IP} /root/app/killps.sh

# copy app to target board
# need to deploy jpeglib to exe path:
# cp ./jpeglib/jpeg/lib/libjpeg.so* .
proc scp ./exe/libjpeg.so* root@${IP}:/usr/lib
proc scp ./exe/${PRJNAME} root@${IP}:${BDPATH}
proc scp ./exe/background.jpg root@${IP}:${BDPATH}
proc scp ../start.sh root@${IP}:/etc/init.d

# starting app
proc ssh root@${IP} ${BDPATH}/${PRJNAME} /dev/video0
